package cn.krund.lyc.hotlerobot.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.krund.lyc.hotlerobot.R;

/**
 * @包名: cn.krund.lyc.hotlerobot.activity.adapter
 * @作者: 刘育成
 * @时间: 2018/3/29  11:45
 * @org: 克路德人工智能
 * @描述: TODO
 * @fileName: GridSelectAdapter
 */

public class GridSelectAdapter extends BaseAdapter {
    private Context mContext;
    private List<String> Datas;
    private LayoutInflater inflater;
    public GridSelectAdapter(Context mContext,List<String> Datas){
        this.mContext=mContext;
        this.Datas=Datas;
        this.inflater = LayoutInflater.from(mContext);
    }
    @Override
    public int getCount() {
        return Datas.size();
    }

    @Override
    public Object getItem(int position) {
        return Datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SearchSelectAdapter.ViewHolder holder = null;
        if (convertView == null ) {
            convertView = inflater.inflate(R.layout.list_cell_select_single, null);
            holder = new SearchSelectAdapter.ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (SearchSelectAdapter.ViewHolder) convertView.getTag();
        }

        holder.info.setText(Datas.get(position));
        return convertView;
    }
    static class ViewHolder {
        TextView info;
        public ViewHolder(View view) {
            info = (TextView) view.findViewById(R.id.tv_select_info);
        }
    }
}
